| Set up StrongED's read and write paths.
|  StrongED developers.

| We're going to need IfThere and Repeat so make sure they're available.
RMEnsure UtilityModule 3.50 If "<Alias$IfThere>" = "" Then Set Alias$IfThere <StrongED$Dir>.Tools.IfThere %%*0

| Check there is a Defaults directory inside !StrongED, if there isn't then it's an error.
IfThere <StrongED$Dir>.Defaults Then Set StrongED_Defaults$Dir <StrongED$Dir>.Defaults Else Error 0 StrongED's Defaults directory not found.

| See if Ctrl is pressed if so then Ctrl$Pressed will be != 0.
SetEval Ctrl$Pressed 0
IfThere <StrongED$Dir>.Tools.TestCtrl Then Run <StrongED$Dir>.Tools.TestCtrl

| See if we can find StrED_cfg and if so set StrED_cfg$Dir to point to it. If Ctrl$Pressed != 0 then only check the directory StrongED is in,
| this makes it easy to see if errors are due to customisation, by keeping/placing a vanilla StrED_cfg in the same directory as StrongED.
Set StrED_cfg$Dir ""
If "<StrED_cfg$Dir>" = "" AND <Ctrl$Pressed> = 0 Then IfThere <Choices$Write>.!StrED_cfg Then Set StrED_cfg$Dir <Choices$Write>.!StrED_cfg
If "<StrED_cfg$Dir>" = "" AND <Ctrl$Pressed> = 0 Then IfThere <StrongED_Settings$Dir>.!StrED_cfg Then Set StrED_cfg$Dir <StrongED_Settings$Dir>.!StrED_cfg
If "<StrED_cfg$Dir>" = "" Then IfThere <StrongED$Dir>.^.!StrED_cfg Then Set StrED_cfg$Dir <StrongED$Dir>.^.!StrED_cfg

| Find version of current StrED_cfg, if it is too old then instruct user to run !UpdateCfg.
SetEval StrED_cfg$Vsn 100
If "<StrED_cfg$Dir>" <> "" Then IfThere <StrED_cfg$Dir>.!Version Then Obey <StrED_cfg$Dir>.!Version
If "<StrED_cfg$Dir>" <> "" Then If StrED_cfg$Vsn < 102 Then Error 0 Your copy of !StrED_cfg is out of date and needs to be updated. To do this run !UpdateCfg, please read the instructions first.

| If there is a !StrED_cfg then it must contain a directory UserPrefs, if it doesn't then it's an error.
If "<StrED_cfg$Dir>" <> "" Then IfThere <StrED_cfg$Dir>.UserPrefs Then Set StrongED_UserPrefs$Dir <StrED_cfg$Dir>.UserPrefs
If "<StrED_cfg$Dir>" <> "" Then If "<StrongED_UserPrefs$Dir>" = "" Then Error 0 StrED_cfg's UserPrefs directory not found.

| Make sure there is a SpellCheck directory in UserPrefs, and move UserDicts directory inside it
If "<StrongED_UserPrefs$Dir>" = "" Then Else IfThere <StrongED_UserPrefs$Dir>.SpellCheck Then Else CDir <StrongED_UserPrefs$Dir>.SpellCheck
If "<StrongED_UserPrefs$Dir>" = "" Then Else IfThere <StrongED_UserPrefs$Dir>.UserDicts Then Rename <StrongED_UserPrefs$Dir>.UserDicts <StrongED_UserPrefs$Dir>.SpellCheck.UserDicts Else CDir <StrongED_UserPrefs$Dir>.SpellCheck.UserDicts

| We can now set up StrongED's read and write paths.
If "<StrongED_UserPrefs$Dir>" = "" Then Set StrongED_Write$Path <StrongED_Defaults$Dir>. Else Set StrongED_Write$Path <StrongED_UserPrefs$Dir>.
If "<StrongED_UserPrefs$Dir>" = "" Then Set StrongED_Read$Path <StrongED_Defaults$Dir>. Else Set StrongED_Read$Path <StrongED_UserPrefs$Dir>.,<StrongED_Defaults$Dir>.

| If there is an Init file in either UserPrefs or Defaults then run it.
IfThere StrongED_Read:Init Then Obey StrongED_Read:Init

| Unset these variables as we no longer need them.
Unset StrED_cfg$Dir
Unset StrongED_Defaults$Dir
Unset StrongED_Settings$Dir
Unset StrongED_UserPrefs$Dir
